package legumes.client;

import legumes.client.services.callbacks.WhoAmICallback;
import legumes.client.services.util.rpc.RPCCallSequencer;
import legumes.client.ui.Authentication;
import legumes.client.ui.LoadingUIManager;
import legumes.client.ui.MainPanel;

import com.google.gwt.core.client.EntryPoint;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class LegumesWeb implements EntryPoint {

	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {
		LoadingUIManager.getInstance().init();
		
		RPCCallSequencer callSequencer = new RPCCallSequencer(
				"Chargement en cours...");
		final WhoAmICallback whoAmICallback = new WhoAmICallback();
		callSequencer.addCall(whoAmICallback);
		callSequencer.addRunnable(new Runnable() {
			public void run() {
				Authentication.setCustomer(whoAmICallback.getCustomerDTO());
				
				MainPanel mp = new MainPanel();
				mp.draw();
				
			}
		});
		callSequencer.callSequence();
	}
}
